﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace demo9
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("----------------欢迎进入游戏世界----------------");
            Console.WriteLine("*******************************");
            Console.WriteLine("**********猜拳比赛*************");
            Console.WriteLine("*******************************");
            Console.WriteLine("游戏规则：1、剪刀 2、石头 3、布");
            Npc d = new Npc();
            player w = new player();
            mora m = new mora();
            while (true)
            {
                bool Q = true;
                d.NpcName();
                w.PlayerName();
                Console.WriteLine("{0}  vs  {1}", w.Name, d.Name);
                Console.WriteLine("要开始对局吗？(y/n)");
                string yn = Console.ReadLine();
                switch (yn)
                {
                    case "y":
                        m.morap();
                        m.moran();
                        Console.WriteLine("{0}: 出招:{1}", w.Name, m.PlayerMora);
                        Console.WriteLine("{0}: 出招:{1}", d.Name, m.NPCMora);
                        m.tend();
                        while (Q)
                        {
                            int record = 0;
                            record++;
                            Console.WriteLine("是否开始下一轮？(y/n)");
                            string q = Console.ReadLine();
                            switch (q)
                            {
                                case "y":
                                    m.morap();
                                    m.moran();
                                    Console.WriteLine("{0}: 出招:{1}", w.Name, m.PlayerMora);
                                    Console.WriteLine("{0}: 出招:{1}", d.Name, m.NPCMora);
                                    m.tend();
                                    break;
                                case "n":
                                    Console.WriteLine("=====================================");
                                    Console.WriteLine("{0}  vs  {1}", w.Name, d.Name);
                                    Console.WriteLine("对战次数：" + record);
                                    Console.WriteLine("姓名\t得分 ");
                                    Console.WriteLine("{0}\t{1}", w.Name, m.Win1);
                                    Console.WriteLine("{0}\t{1}", d.Name, m.Defeat1);
                                    if (m.Win1 > m.Defeat1)
                                    {
                                        Console.WriteLine("结果：{0}赢,{1}不行不行", w.Name, d.Name);
                                    }
                                    else if (m.Win1 < m.Defeat1)
                                    {
                                        Console.WriteLine("结果：{0}赢,{1}不行不行", d.Name, w.Name);
                                    }
                                    else if (m.Win1 == m.Defeat1)
                                    {
                                        Console.WriteLine("结果：平局");
                                    }
                                    Q = false;
                                    break;
                            }
                        }
                        break;
                    case "n":
                        Console.WriteLine("不玩你进来干嘛？？？");
                        break;
                }
                Console.WriteLine("是否开始下一局？（y/n）");
                string u = Console.ReadLine();
                if (u == "y")
                {
                    continue;
                }
                else if (u == "n")
                {
                    Console.WriteLine("游戏结束!");
                    break;
                }
            }
        }
    }
}
